#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int N=2e5+7;
mt19937_64 rnd(19260817);
int n,m,u[N],v[N],fa[N];
ull w[N],vl[N];bool vis[N];
bool used[N];
vector<pair<int,int>>e[N];
vector<int>p[N];
void dfs(int x){
    vis[x]=1;
    for(auto vv:e[x]){
        if(!vis[vv.first]){
            vis[vv.first]=1;
            used[vv.second]=1;
            fa[vv.first]=x;
            p[x].push_back(vv.first);
            dfs(vv.first);
        }
    }
    return;
}
void dfs2(int x){
    for(auto vv:p[x]){
        if(vv){
            dfs2(vv);
            vl[x]^=vl[vv];
        }
    }
    return;
}
int tot,jl[22];
ll bs[61];
bool add(ll v){
    for(int i=60;i>=0;i--)
        if(v&(1ll<<i)){
            if(!bs[i]){
                bs[i]=v;
                return 1;
            }else v^=bs[i];
        }
    return 0;
}
void solve(){
    cin>>tot;
    for(int i=1;i<=tot;i++)
        cin>>jl[i];
    memset(bs,0,sizeof(bs));
    for(int i=1;i<=tot;i++)
        if(!add(w[jl[i]]&((1ll<<60)-1))){
            cout<<"NO\n";
            return;
        }
    cout<<"YES\n";
    return;
}
signed main(){
    freopen("graph.in","r",stdin);
    freopen("graph.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>u[i]>>v[i];
        w[i]=rnd();
        e[u[i]].push_back({v[i],i});
        e[v[i]].push_back({u[i],i});
    }
    dfs(1);
    for(int i=1;i<=m;i++){
        if(!used[i]){
            vl[u[i]]^=w[i];
            vl[v[i]]^=w[i];
        }
    }
    dfs2(1);
    for(int i=1;i<=m;i++)
        if(used[i]){
            if(fa[v[i]]==u[i])
                w[i]=vl[v[i]];
            else
                w[i]=vl[u[i]];
        }
    int q;
    cin>>q;
    while(q--)solve();
    return 0;
}
